
# initialize
library(class)
library(e1071)
source("./config")
source("./fun.R")

# Naive Bayes Classifier
NBC.cl <- naiveBayes(Topic ~ ., r.train, laplace = laplace_smoothing)
NBC.pr <- predict(NBC.cl, r.test[,-n])

# Error rate
NBC.er <- sum(as.character(r.test[,n]) == as.character(NBC.pr))/length(r.test[,n])

# other quality measures
NBC.sen <- sensitivity_M(as.character(r.test[,n]), as.character(NBC.pr))
NBC.spe <- specificity_M(as.character(r.test[,n]), as.character(NBC.pr))
NBC.fm <- Fmeasure(as.character(r.test[,n]), as.character(NBC.pr))
NBC.ta <- TA(as.character(r.test[,n]), as.character(NBC.pr))

